package com.twu.biblioteca;

/**
 * Created by aswathik on 6/20/14.
 */
public class LogOut implements MenuItem {
    private String menuString;
    LogOut() {
        menuString = "Log Out";
    }

    @Override
    public String getMenuString() {
        return menuString;
    }

    public MenuActionResult performMenuAction(UserInterface userInterface) {
        MenuActionResult menuActionResult = new MenuActionResult();
        if ( LoginValidator.getCurrentUser() != null ) {
            LoginValidator.logout();
            menuActionResult.setMenuActionDetails(true,"Successfully Logged out!");
        } else {
            menuActionResult.setMenuActionDetails(false,"You are not logged in!");
        }
        userInterface.displayMenuActionResult(menuActionResult);
        return menuActionResult;
    }
}
